<!-- 项目基本信息 -->
<template>
  <u-collapse-item ref="initcollapse">
    <text slot="title" class="u-page__title">项目基础信息</text>
    <text class="u-collapse-content">
      <iframe v-if="this.prjType==='M'" :src="baseDetailsUrl" scrolling="no" width="100%" :height="basicHeight" frameborder="0" />
    </text>
  </u-collapse-item>
</template>
<script>
const config = [
  {
    type: ['M'], // M = IT投资类类项目
    iframeUrl: 'inspur/inspectionAndValuation/components/baseView',
    iframeHeight: 'basicHeight'
  },
  {
    type: ['A', 'B', 'C', 'G', 'Z'], // A = 铁塔类项目, B = 室分类项目, C = 传输类项目, G = 微姑类项目, Z = 整体项目
    iframeUrl: '',
    iframeHeight: 'basicHeight'
  }
]
export default {
  name: 'JnPrjDetail',
  components: {},
  props: {
    prjId: {
      type: String,
      default: '',
      required: true
    },
    prjType: {
      type: String,
      required: false
    }
  },
  data() {
    return {
      basicHeight: ''
    }
  },
  computed: {
    currentConfig() {
      return config.find(item => item.type.includes(this.prjType || 'M'))
    },
    baseDetailsUrl() {
      // return `http://10.180.30.52:8090/pms-center-app/#/${this.currentConfig.iframeUrl}?prjId=30016994&sysToken=c64dd4dac160904f76a09c81b078228a`
      console.log('地址', process.uniEnv.BASE_JN_URL)
      let sysToken = uni.getStorageSync('sysToken')
      return `${process.uniEnv.BASE_JN_URL}/#/${this.currentConfig.iframeUrl}?sysToken=${sysToken}&prjId=${this.prjId}`
    }
  },
  mounted() {
    window.addEventListener('message', (event) => {
        const base_url = ''
        if (event.origin === base_url) {
            return
        }
          if (event.data.type === 'getBasicinfo') {
            this.basicHeight = event.data.params.height
            this.$nextTick(()=>{
              this.$refs.initcollapse.init()
            })
          }
    })
  },
}
</script>
<style>
@import "@/common/uView.css";
</style>
<style scoped lang='scss'></style>
